efform_onload = function ()
{ 
 
	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCD11","query");  
}; 
button_query_onclick = function (){
	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCD11","query"); 
}
button_insert_onclick = function (){
	if (isSelected("ef_grid_r") == 0)return; 
//	efgrid.submitForm( "ef_grid_r", "ZM","ZMCD11","insert",true);
	var info = getSCZXEiInfos("ZMCD11","ef_grid_r");
	if (null != info) { 
		EiCommunicator.send("ZMCD11", "validate", info, validate_callback);
	}
}
button_update_onclick = function (){
	if (isSelected("ef_grid_r") == 0)return; 
//	efgrid.submitForm( "ef_grid_r", "ZM","ZMCD11","update",true);
	var info = getSCZXEiInfos("ZMCD11","ef_grid_r");
	if (null != info) { 
		EiCommunicator.send("ZMCD11", "validate", info, validate_callback);
	}
}
button_delete_onclick = function (){
	if (isSelected("ef_grid_r") == 0)return; 
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r){
			efgrid.submitForm( "ef_grid_r", "ZM","ZMCD11","delete",true);
			$('#categoryTree').reload();//刷新树
		}
	});
} 
var validate_callback={
		onSuccess:function(eiInfo){
			if(eiInfo.getStatus()==-1){
				EFAlert("操作失败，原因："+eiInfo.getMsg());
			}else{
/*				 efwindow.hide();
				 var grid = efgrid.getGridObject("ef_grid_result");
				 grid.refresh(eiInfo);*/
				var oper="insert";
				if(eiInfo.get("efCurButtonEname")=="UPDATE"){
					oper="update";
				}
				efgrid.submitForm("ef_grid_r", "ZM", "ZMCD11",oper, true);
			}
		},
		onFail:function(eMsg)
		{
			EFAlert("操作失败，原因："+eMsg); 
		}
}
efgrid_afterAddNewRow = function(grid_id){ 

	var grid = efgrid.getGridObject(grid_id);
	var rows = grid.getCheckedRows();  
	if(grid_id=="ef_grid_r")
	{
		var fdSuperDirId=$('#fdSuperDirId').val(); 
		var fdDirType=$('#fdDirType').val(); 
		var fdCreatorId=$('#fdCreatorId').val(); 
		var fdCreateDepartmentId=$('#fdCreateDepartmentId').val();  
	   
		for(var i = 0 ; i < rows.length;i++){
			grid.getBlockData().setCell(rows[i], "fdKeyId", "");
			grid.getBlockData().setCell(rows[i], "fdDepartmentId", fdCreateDepartmentId);
			grid.getBlockData().setCell(rows[i], "fdCreatorId", fdCreatorId);
			grid.getBlockData().setCell(rows[i], "fdSuperDirId", fdSuperDirId);
			grid.getBlockData().setCell(rows[i], "fdDirType", fdDirType);
		}
	}
}